home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
gnu
/
gawk
/
gawk213s.zoo
/
gawk-src-2.13
/
vms
/
gawk.hlp
< prev
next >
Wrap
Text File
|
1991-06-19
|
59KB
|
1,157 lines
! Gawk.Hlp
! Pat Rankin, Jun'90
! revised, Jun'91
! Online help for GAWK.
!
1 GAWK
GAWK is GNU awk, the Free Software Foundation's implementation of
the awk programming language. awk is an interperative language which
can handle many data-reformatting jobs with just a few lines of code.
It has powerful string manipulation and pattern matching capabilities
built in. This version should be compatable with POSIX 1003.2 awk.
The VMS version of GAWK supports both the original UN*X-style command
interface and a DCL interface. The only setup requirement for GAWK
is to define it as a 'foreign' command: a DCL symbol with a value
which begins with '$'.
$ GAWK :== $disk:[directory]GAWK
2 GNU_syntax
GAWK's UN*X-style interface uses the 'dash' convention for specifying
options and uses spaces to separate multiple arguments.
There are two main alternatives, depending on how the awk program is
to be passed to GAWK. Both alternatives share most options.
Usage: $ gawk [-W opts] [-F fs] [-v var=val] -f progfile [--] file ...
or $ gawk [-W opts] [-F fs] [-v var=val] [--] "program" file ...
The options are case-sensitive. On VMS, the DCL command interpreter
converts unquoted text into uppercase before passing it to the running
program. However, GAWK is written in 'C' and the C Run-Time Library
(VAXCRTL) converts unquoted text into *lowercase*. Therefore, the
-Fval and -W options must be enclosed in quotes.
3 options
-f file use the specified file as the awk program source; if more
than one instance of -f is used, each file will be read
in succession
-Fstring define a value for the FS variable (field separator)
-v var=val assign a value of 'val' to the variable 'var'
-W 'options' additional gawk-specific options; multiple values may
be separated by commas, or by spaces if they're quoted,
or mulitple occurences of -W may be used.
-W compat use awk "compatibility mode" to disable GAWK extensions
and get the behavior of UN*X awk.
-W copyright [or -W copyleft] display an abbreivated version of
the GNU copyright information
-W lint warn about suspect or non-portable awk program code
-W posix compatibility mode with additional restrictions
-W version display program version number
-- don't check further arguments for leading dash
3 program_text
If the '-f file' option is not used on the command line, then the
first "non-dash" argument is assumed to be a string of text containing
the awk source program. Here is a complete sample program:
$ gawk -- "BEGIN {print ""\nHello, World!\n""}"
This program would print a blank line (based on first "\n"), followed
by a line reading "Hello, World!", followed by another blank line
(since awk's 'print' statement includes trailing 'newline').
On VMS, to include a quote character inside of a quoted string, two
successive quotes ("") must be used.
3 data_files
After all dash-options are examined, and after the program text if
there were no occurences of the -f option, remaining (space separated)
command line arguments are considered to be data files for the awk
program to process. If any of these actually contains an equals sign
(=), then it is interpreted as a variable assignment instead of a data
file. The syntax is 'variable_name=value'. For example, the command
$ gawk -f myprog.awk infile.one flag=2 start=0 infile.two
would read file 'infile.one' for the program in 'myprog.awk', then it
would set 'flag' to 2 and 'start' to 0, and finally it would read file
'infile.two' for the program. Note that in a case like this, the two
assignments actually occur after the first file has been processed,
not at program startup when the command line is first scanned.
3 IO_redirection
The command parsing in the VMS implementation of GAWK does some
emulation of a UN*X-style shell, where certain characters on the
command line have special meaning. In particular, the symbols '<',
'>', '|', '*', and '?' receive special handling before the main part
of the program has a chance to see them. The symbols '<' and '>'
perform some file manipulation from the command line:
<ifile open file 'ifile' (readonly) as 'stdin' [SYS$INPUT]
>nfile create 'nfile' at 'stdout' [SYS$OUTPUT], in stream-lf format
>>ofile append to 'ofile' for 'stdout'; create it if necessary
>&efile point 'stderr' [SYS$ERROR] at 'efile', but don't open it yet
>$vfile create 'vfile' as 'stdout', using RMS attributes appropriate
for a standard text file (variable length records with
implied carriage control)
2>&1 route error messages into the regular output stream
1>&2 send output data to the error destination
<<sentinal error; reading stdin until 'sentinal' not supported
<-, >- error; closer of stdin or stdout from cmd line not supported
>>$vfile incorrect; would be interpreted as file "$vfile" in stream-lf
format rather than as file "vfile" in RMS 'text' format
| error; command line pipes not supported
3 wildcard_expansion
The command parsing in the VMS implementation of GAWK does some
emulation of a UN*X-style shell, where certain characters on the
command line have special meaning. In particular, the symbols '<',
'>', '*', '%', and '?' receive special handling before the main part
of the program has a chance to see them. The symbols '*', '%' and '?'
are used as wildcards in filenames. '*' and '%' have their usual VMS
meanings of multiple character and single character wildcards,
respectively, and '?' is also treated as a single character wildcard.
When a command line argument that should be a filename contains any
of the wildcard characters, a directory lookup is attempted for files
which match the specified pattern. If one or more matching files are
found, those filenames are put into the command line in place of the
original pattern. If no matching files are found, the original
pattern is left in place.
2 DCL_syntax
GAWK's DCL-style interface is more or less a standard DCL command, with
one required parameter. Multiple values--when present--are separated
by commas.
There are two main alternatives, depending on how the awk program is
to be passed to GAWK. Both alternatives share most options.
Usage: GAWK /COMMANDS="awk program text" data_file[,data_file,...]
or GAWK /INPUT=awk_file data_file[,"Var=value",data_file,...]
( or GAWK /INPUT=(awk_file1,awk_file2,...) data_file[,...] )
3 Parameter
data_file[,datafile,...] (data_file data_file ...)
data_file[,"Var=value",...,data_file,...] (data_file Var=value &c)
Data file(s) for the awk program to process. If any of these
actually contains an equals sign (=), then it is interpreted as
a variable assignment instead of a data file. The syntax is
"variable_name=value". Quotes are required for non-file parameters.
For example, the command
$ gawk/input=myprog.awk infile.one,"flag=2","start=0",infile.two
would read file 'infile.one' for the program in 'myprog.awk', then it
would set 'flag' to 2 and 'start' to 0, and finally it would read file
'infile.two' for the program. Note that in a case like this, the two
assignments actually occur after the first file has been processed,
not at program startup when the command line is first scanned.
Wildcard file lookups are attempted on data file specifications. See
subtopic 'GAWK GNU_syntax wildcard_expansion' for details.
At least one data_file parameter value is required. An exception is
made if /usage, /version, or /copyright is specifed *and* if GAWK is
defined as a 'foreign' command rather than a 'native' DCL command.
3 Qualifiers
/COMMANDS
/COMMANDS="awk program text" (-- "awk program text")
For short programs, it is possible to include the complete program
on the command line. The quotes are required. Here is a complete
sample program:
$ gawk/commands="BEGIN {print ""\nHello, W